{extend name="$index_style_layout" /}
{block name="head_title"}{$info.title} {:M('name')}{/block}

{block name="body_content"}
<link rel="stylesheet" href="__STATIC__/group/index.css">
<div class="MainContainer">

<div style="margin-top:10px;padding-left:10px;background:#fff;">
{include file="../../default/qun/common/mysort" /}
</div>

	<div class="ShowContentType">
		<div class="tags"><span class="ck">最新资讯</span><span>热门资讯</span><span>推荐资讯</span></div>
		<div class="Contents">
			{qb:tag name="qun_wapindex_cms_model001" union="order,by"  where="uid=$info.uid&myfid=$myfid" type="cms" rows="5"}
			<div class="lists">
				<ul>
					<li class="img"><a href="{:get_url('user',$rs.uid)}"><img src="{$rs.user_icon}" onerror="this.src='__STATIC__/images/nobody.gif'"></a></li>
					<li class="info"><span>{$rs.username}</span><em>{$rs.time}</em></li>
					<li class="more"><span>{if ($rs.status>1)}精{elseif (time()-$rs.create_time<3600*24)}新{elseif ($rs.view>10)}热{/if}</span></li>
				</ul>
				<a href="{$rs.url}">
				<dl>
					<dt>{$rs.title}</dt>
					{if (count($rs['picurls'])>2)}
					<dd>
						{volist name="rs.picurls" id="vs"}
						{lt name="i" value="4"}<div><span><img src="{$vs.picurl}" onerror="this.src='__STATIC__/images/nopic.png'"></span></div>{/lt}
						{/volist}
					</dd>
					{/if}
				</dl>
				</a>
				<div class="others">
					<span><i class="fa fa-thumbs-o-up">{$rs.agree}</i></span>
					<em><i class="fa fa-commenting-o">{$rs.replynum}</i></em>
					<em class="remove" style="display:none" data-id="{$rs.id}"><i class="glyphicon glyphicon-trash"></i></em>
				</div>
			</div>
			{/qb:tag}
		</div>
		<div class="Contents"></div>		
		
		<div class="Contents"></div>			
		
		<div class="ShowMores"><span>查看更多</span></div>
	</div>
</div>

<script type="text/javascript">
var ajax_url_db = ['&order=id&by=desc&','&order=view&by=desc&','&order=status&by=desc&'];
var choose_i = 0; //选中第几项
var haveshowpage = []; //每一项,作个标志,已经已显示到第几页
//    haveshowpage[0] = 1;

//显示更多
function showMoreContent(){	
	var url = ajax_url_db[choose_i];	//第几项对应的网址
	haveshowpage[choose_i]++;
	$.get('{qb:url name="qun_wapindex_cms_model001"/}' + haveshowpage[choose_i] + "&myfid={$myfid}" + url + Math.random(),function(res){
		if(res.code==0){
			if(res.data==''){
				layer.msg("已经显示完了！",{time:500});
				$('.ShowMores').off("click");
				$('.ShowMores span').html('显示完了');
				$('.ShowMores span').css({'background':'#eee'});
			}else{
				if(haveshowpage[choose_i]==1){
					$('.ShowContentType .Contents').eq(choose_i).html(res.data);
				}else{
					$('.ShowContentType .Contents').eq(choose_i).append(res.data);
				}
				scroll_get = true;
				admin_do();	
			}
		}else{
			layer.msg(res.msg,{time:2500});
		}
	});
}


//切换显示
function showContentType(num){

	choose_i = num;
	$('.ShowMores').off("click");	//先移除,避免重复加多次click事件
	$('.ShowMores').on("click",showMoreContent);
	$('.ShowMores span').html('查看更多');

	if(haveshowpage[num]==undefined){
		haveshowpage[num] = 0;
		showMoreContent();
	}

	$('.ShowContentType .tags span').removeClass('ck');
	$('.ShowContentType .tags span').eq(num).addClass('ck');
	$('.ShowContentType .Contents').hide();
	$('.ShowContentType .Contents').eq(num).show();
}
$('.ShowContentType .tags span').click(function(){
	var thisnum=$(this).index();
	showContentType(thisnum);
});
showContentType(0);

//滚动显示更多
var scroll_get = true;	//做个标志,不要反反复复的加载
$(document).ready(function () {
	$(window).scroll(function () {
		if (scroll_get==true &&  (400 + $(window).scrollTop())>($(document).height() - $(window).height())) {
			scroll_get = false;			
			layer.msg('内容加截中,请稍候',{time:1500});
			showMoreContent();
		}
	});
});


function addpost(){
	var obj = $('.MorePost');
	obj.is(':hidden') ? obj.show() : obj.hide();
}



//圈主操作
function admin_do(){
	if("{$power}"!=2 && "{$power}"!=3){
		return ;	//非管理员
	}
	$(".Contents .remove").each(function(){
		var obj = $(this);
		$(this).show();
		var id = $(this).data('id');
		$(this).on("click",function(){
			$.get("{:urls('wxapp.bbs/remove',['aid'=>$aid])}?id=" + id,function(res){
				if(res.code==0){
					layer.msg("成功移除",{time:500});
					obj.parent().parent().hide();
				}else{
					layer.msg("移除失败"+res.msg,{time:2500});
				}
			});
		});
	});	
}

</script>
{/block}